package fetchHolidays

import (
	"Holidays/model"
	"time"
	/*"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"*/)

// FetchHolidays 模拟从爬虫或其他API获取节假日数据的函数
func FetchHolidays(year int) ([]model.Holiday, error) {
	/*// 这里应该是实际的爬虫逻辑或API调用
	// 假设URL模式为：https://example.com/holidays/{year}
	url := fmt.Sprintf("http://v.juhe.cn/calendar/year?key=c6ba47a09297a620040b972864399eec&year=%d", year)
	// 发送HTTP GET请求
	resp, err := http.Get(url)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// 读取响应体
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	fmt.Println("=================", body)

	// 解析JSON响应
	var holidays []model.Holiday
	err = json.Unmarshal(body, &holidays)
	if err != nil {
		return nil, err
	}
	fmt.Println("11111111111111111")
	fmt.Println(holidays)
	// 假设我们已经有了节假日数据，现在返回它
	return holidays, nil*/

	holidays := []model.Holiday{
		{Name: "元旦", Date: time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)},
		{Name: "春节", Date: time.Date(year, 2, 1, 0, 0, 0, 0, time.UTC)},
		{Name: "清明节", Date: time.Date(year, 3, 1, 0, 0, 0, 0, time.UTC)},
		{Name: "劳动节", Date: time.Date(year, 5, 1, 0, 0, 0, 0, time.UTC)},
		{Name: "儿童节", Date: time.Date(year, 6, 1, 0, 0, 0, 0, time.UTC)},
	}

	return holidays, nil

}
